/*
 * @lc app=leetcode.cn id=1518 lang=typescript
 *
 * [1518] 换酒问题
 */

// @lc code=start
function numWaterBottles(numBottles: number, numExchange: number): number {
    let counter = numBottles;
    let now = numBottles;
    while (now >= numExchange) {
        const newB = Math.floor(now / numExchange);
        counter += newB;
        const last = now % numExchange;
        now = newB + last;
    }
    return counter;
}
// @lc code=end
